package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.shop.ShopReturnAddressDto;
import com.java110.intf.shop.IShopReturnAddressInnerServiceSMO;
import com.java110.po.shop.ShopReturnAddressPo;
import com.java110.mall.shop.dao.IShopReturnAddressServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 退货地址内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopReturnAddressInnerServiceSMOImpl extends BaseServiceSMO implements IShopReturnAddressInnerServiceSMO {

    @Autowired
    private IShopReturnAddressServiceDao shopReturnAddressServiceDaoImpl;


    @Override
    public int saveShopReturnAddress(@RequestBody ShopReturnAddressPo shopReturnAddressPo) {
        int saveFlag = 1;
        shopReturnAddressServiceDaoImpl.saveShopReturnAddressInfo(BeanConvertUtil.beanCovertMap(shopReturnAddressPo));
        return saveFlag;
    }

    @Override
    public int updateShopReturnAddress(@RequestBody ShopReturnAddressPo shopReturnAddressPo) {
        int saveFlag = 1;
        shopReturnAddressServiceDaoImpl.updateShopReturnAddressInfo(BeanConvertUtil.beanCovertMap(shopReturnAddressPo));
        return saveFlag;
    }

    @Override
    public int deleteShopReturnAddress(@RequestBody ShopReturnAddressPo shopReturnAddressPo) {
        int saveFlag = 1;
        shopReturnAddressPo.setStatusCd("1");
        shopReturnAddressServiceDaoImpl.updateShopReturnAddressInfo(BeanConvertUtil.beanCovertMap(shopReturnAddressPo));
        return saveFlag;
    }

    @Override
    public List<ShopReturnAddressDto> queryShopReturnAddresss(@RequestBody ShopReturnAddressDto shopReturnAddressDto) {

        //校验是否传了 分页信息

        int page = shopReturnAddressDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopReturnAddressDto.setPage((page - 1) * shopReturnAddressDto.getRow());
        }

        List<ShopReturnAddressDto> shopReturnAddresss = BeanConvertUtil.covertBeanList(shopReturnAddressServiceDaoImpl.getShopReturnAddressInfo(BeanConvertUtil.beanCovertMap(shopReturnAddressDto)), ShopReturnAddressDto.class);

        return shopReturnAddresss;
    }


    @Override
    public int queryShopReturnAddresssCount(@RequestBody ShopReturnAddressDto shopReturnAddressDto) {
        return shopReturnAddressServiceDaoImpl.queryShopReturnAddresssCount(BeanConvertUtil.beanCovertMap(shopReturnAddressDto));
    }

    public IShopReturnAddressServiceDao getShopReturnAddressServiceDaoImpl() {
        return shopReturnAddressServiceDaoImpl;
    }

    public void setShopReturnAddressServiceDaoImpl(IShopReturnAddressServiceDao shopReturnAddressServiceDaoImpl) {
        this.shopReturnAddressServiceDaoImpl = shopReturnAddressServiceDaoImpl;
    }
}
